package com.jihox.abookpro.util;

import com.thoughtworks.xstream.mapper.Mapper;
import com.thoughtworks.xstream.mapper.MapperWrapper;

public class MyMapperWrapper extends MapperWrapper {

	public MyMapperWrapper(Mapper wrapped) {
		super(wrapped);
	}

	public String serializedMember(Class type, String memberName) {
		// object -> xml 首字母转大写
		if (memberName!= null && !memberName.isEmpty() && !"xmlns".equals(memberName)) {
			memberName = memberName.substring(0, 1).toUpperCase()
					+ memberName.substring(1);
		}
		return super.serializedMember(type, memberName);
	}
	
	public String realMember(Class type, String serialized) {
		// xml -> object 首字母转小写
		if (serialized!= null && !serialized.trim().isEmpty() && !"xmlns".equals(serialized)) {
			serialized = serialized.substring(0, 1).toLowerCase()
					+ serialized.substring(1);
		}
		return super.realMember(type, serialized);
	}
}

